/**
 * @author Maximilian Csuk
 * @author Konrad Paumann
 * @author Bernhard Denner
 */

public class Addition extends BinOp {
	
	public Addition(Node leftChild, Node rightChild ) {
		super(leftChild, rightChild);
	}
	/**
	 * Returns the result of the evaluation
	 */
	public Number eval() {
		Number x = super.getLeftChild().eval(); 
		Number y = super.getRightChild().eval();
		
		if (x.getClass() == y.getClass()) {
			
			if (x instanceof MyInteger) {
				return new MyInteger(((MyInteger)x).getValue() + 
						((MyInteger)y).getValue());
			}
			
			if (x instanceof MyFloat) {
				return new MyFloat(((MyFloat)x).getValue() + 
						((MyFloat)y).getValue());
			} else
				return new NotaNumber();
			
		} else {
			return new NotaNumber();
		}
	}
}
